<script type="text/javascript" src="js/services.js"></script>
<link type="text/css" rel="stylesheet" href="css/services.css"/>
﻿<div class="container type1">
<script>
$(function(){
	$( "#phatsinh_dt" ).datepicker({
			showOn: "button",
			changeYear:true,
			changeMonth:true,
			buttonImage: "<?php echo base_url();?>resources/images/calendar.gif",
			buttonImageOnly: true,
			dateFormat: 'mm/yy',
			onClose: function(dateText, inst) { 
            var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
            var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
            $(this).datepicker('setDate', new Date(year, month, 1));
        },			
		}).change(function(){
			
		});
});
</script>
<style>
    .ui-datepicker-calendar {
        display: none;
    }
    #form_ps{
		margin: 50px auto 0;
		width: 220px;
    }
    
    .type1{
        float: none;
    }
	.action{padding-right:0px;}
	#phatsinh_dt{}
</style>
		<h1>Danh sách phát sinh</h1>
<?php echo form_open(current_url(), 'id="form_ps"'); ?>	
  
	<input id="phatsinh_dt" type="text" name="phatsinh_dt" value="<?php echo $time;?>"  />
	 <input type="image" id="button_submit" name="button_submit" value="Liệt kê" class="imageButtonSmall" style="width: 42px; padding-left: 30px; margin-top: 7px; margin-left: 62px;"/>
     
	<?php echo form_close(); ?>	
		<div id = "top_reserve">
			<div id = "content-right" class="action">
			
                            <div id="add_new">
				<p>
				<?php
                    if( isset( $action )){
                        foreach($action as $a){
                            if( strtolower($a['id']) == 'new'){
                                echo anchor( base_url( ) . $a['url'], $a['label'] );
                                break;
                            }
                        }
                    } 
                        
                ?>
				</p>
			</div>
			</div>
		</div>



    <table>
	<tr>
	  <?php

                foreach( $rules as $i ){
                    if( in_array( $i[ 'field_id' ], $master_limited  ) )
                        echo "<th class='".$i['class']."' style='".$i['style']."'>". $i[ 'label' ]."</th>";
                }
            ?>
            <th class="last">Chức năng</th>
	</tr>
	 <?php
                for( $i = 0; $i < count( $results ); $i++ ){
					$odd="";
					if($i%2!=0) $odd="odd";
                    echo "<tr class='$odd'>";
                            foreach( $rules as $item ){
                           	    if( $item[ 'field_id' ] != "Image_ID" && in_array( $item[ 'field_id' ], $master_limited ) ){	        
         			                echo "<td>";
									if($item[ 'control' ] == "time")
										echo date("d/m/y",$results[ $i ][ $item[ 'field_id' ] ]);
									else if($item[ 'control' ] == "vnd") 
										echo formatcurrency($results[ $i ][ $item[ 'field_id' ] ] * 1000);
									else echo $results[ $i ][ $item[ 'field_id' ] ];
            						echo "</td>";					
    					}?>
                         
                        <?php 
                            }
                        echo "<td>";
                            if( isset( $action ) ){
                                foreach($action as $a){
                                    if( strtolower($a['id']) == 'edit'){
                                        echo $results[ $i ][ $a['label'] ] . " ";
                                        break;
                                    }
                                }
                                foreach($action as $a){
                                    if( strtolower($a['id']) == 'delete'){
                                        echo $results[ $i ][ $a['label'] ] . " ";
                                        break;
                                    }
                                }
                            }
                      
                            if( isset( $custom_action ) ){
                                
                                foreach( $custom_action as $item ){
                                //    $a = explode( '=', $item );
                                //    if( isset( $a[ 0 ] ) )
                                        echo $results[$i][$item['action_name']]. "  ";
                                }
                            }
                        echo "</td>";
                    echo "</tr>";
                }
            ?>
	</table>

</div>